<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<div class="modal fade" id="ocean-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">数据权限</h4>
            </div>
            <div class="modal-body">
                <div class=" form">
                    <form class="form-horizontal" id="menu-form" method="post"
                          data-url="resources/role/flushAllowedOperation" data-class="">
                        <input type="hidden" id="role" name="role" value="${role}">
                        <c:forEach var="item" items="${operations}">
                            <div class="form-group">
                                <label class="control-label col-lg-2">${item.key}</label>
                                <div class="col-lg-10">
                                    <c:forEach items="${item.value}" var="operation">
                                        <label class="checkbox col-lg-4">
                                            <input id="${operation.id}" name="operation" type="checkbox"
                                                   value="${operation.id}"> ${operation.name}
                                        </label>
                                    </c:forEach>
                                </div>
                            </div>
                        </c:forEach>
                        <div class="form-group">
                            <div class="col-lg-offset-2 col-lg-10">
                                <button class="btn btn-success" type="button" onclick="formSubmit()">Save
                                </button>
                                <button class="btn btn-default" type="button" data-dismiss="modal">Cancel</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="application/javascript">
    $.post("resources/role/operation", {role: $("#role").val()}, function (data) {
        console.log(data);
        $.each(data, function (index, item) {
            $("#" + item.id).attr("checked", true);
        });
    });
</script>